/*
 * @Author: lp 654528967@qq.com
 * @Date: 2022-06-20 17:06:05
 * @LastEditors: lp 654528967@qq.com
 * @LastEditTime: 2022-06-20 17:33:33
 * @FilePath: \nien-vue3-admin\src\views\myMission\hooks\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { reactive, toRef } from 'vue'

export async function approvalHistory({ row, visible, api, key }) {
  const rowLoading = toRef(row, 'loading'),
    data = reactive<{
    historyTaskVoList:[any],
    processKey:string,
    businessParam:string
  }>({ historyTaskVoList: [{}], processKey: '', businessParam: '' })
  try {
    rowLoading.value = true
    const res = await api(row[key])
    if (res.code === 200) {
      const { historyTaskVoList, processKey, businessParam } = res.data
      data.historyTaskVoList = historyTaskVoList
      data.processKey = processKey
      data.businessParam = JSON.parse(businessParam) 
      visible.value = true
    }
    return {
      data,
    }
  } finally {
    rowLoading.value = false
  }
}